package com.fyy.aop.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;

/**
 * @Author fyy
 * @Description 参数拦截器
 * @Date 2021/6/29 14:11
 */
@Aspect
@Component
public class ParamsAop {

    //AOP切点
    @Pointcut("execution(public * com.fyy.aop.controller..*(..)))")
    public void BrokerAspect(){

    }

    @Before("BrokerAspect()")
    public void doBefore(JoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        for (Object arg : args) {
            if (arg instanceof Model){
                Model model = (Model) arg;
                model.addAttribute("userName","送变电");
            }
        }
    }

}
